package main

import (
	"fmt"
)

// comment
/* comment */
/*
	comment
*/
func main() {
	float()

	num0 := 1
	num1 := 3
	max := max(num0, num1)
	fmt.Printf("max num is %d \n", max)

	testGetSequence()

	testUserStruct()
}

func float() {
	var balance = [...]float32{1000.0, 2.0, 3.4, 7.0, 50.0}
	for i := 0; i < len(balance); i++ {
		fmt.Printf("balance is %f \n", balance[i])
	}
}

func max(num0, num1 int) int {
	if num0 > num1 {
		return num0
	}
	return num1
}

func getSequence() func() int {
	i := 0
	fmt.Printf("i value is %d \n", i)
	return func() int {
		i++
		return i
	}
}

func testGetSequence() {
	/* nextNumber 为一个函数，函数 i 为 0 */
	nextNumber := getSequence()

	/* 调用 nextNumber 函数，i 变量自增 1 并返回 */
	fmt.Println(nextNumber())
	fmt.Println(nextNumber())
	fmt.Println(nextNumber())

	/* 创建新的函数 nextNumber1，并查看结果 */
	nextNumber1 := getSequence()
	fmt.Println(nextNumber1())
	fmt.Println(nextNumber1())
}

/*
User info
*/
type User struct {
	name string
	age  int
	sex  int
}

func testUserStruct() {
	user := User{"kyle", 18, 1}
	user.age = 28
	fmt.Println(user)
	fmt.Println(User{name: "jeff", sex: 1, age: 90})
}
